package com.training.java.core.homework01;

public class Bicycle {

	// Variables
	private final String serialNumber = "ACCELL-2420106";
	private final double maxSpeed = 50;
	private double speed;
	private String gearType;
	private int gear;

	// Methods
	Bicycle(String gearType) {
		this.speed = 0;
		this.gearType = gearType;
		this.gear = 0;

		System.out.println("A Bicycle object, " + serialNumber
				+ " with gear type " + gearType + " is instantiated.");
	}

	public void accelerate(double speed) {
		double currentSpeed = this.speed;

		if ((this.speed + speed) >= maxSpeed) {
			this.speed = maxSpeed;
		} else {
			this.speed += speed;
		}

		System.out.println(serialNumber + " accelerated from " + currentSpeed
				+ " to " + this.speed);
	}

	public void gearUp() {
		switch (this.gearType) {
		case "A":
			if (this.gear == 3) {
				System.out.println("Your gear type is " + gearType + " can't be higher than 3");
			} else {
				this.gear += 1;
				System.out.println("Your current gear is " + this.gear + " " + gearType);
			}
			break;
		case "B":
			if (this.gear == 4) {
				System.out.println("Your gear type is " + gearType + " can't be higher than 4");
			} else {
				this.gear += 1;
				System.out.println("Your current gear is " + this.gear + " " + gearType);
			}
			break;
		case "C":
			System.out.println("Your gear type is " + gearType + " can't change");
			break;
		default:
			System.out
					.println("Your current gear type is invalid, valid types are A, B, C");
			break;
		}
	}

	public double getSpeed() {
		return this.speed;
	}

	public String getType() {
		return this.gearType;
	}

	public int getGear() {
		return this.gear;
	}

}
